<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateEventInfoTable extends Migration
{
    private $table_name = 'event_info';
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable($this->table_name)) {
            Schema::create($this->table_name, function (Blueprint $table) {
                $table->increments('id');
                $table->string('title');
                $table->dateTime('begin_at');
                $table->dateTime('end_at');

                $table->timestamps();
                $table->softDeletes();
            });

            DB::table($this->table_name)->insert(
                [
                    'id' => 1000,
                    'title' => '2018送年历',
                    'begin_at' => \Carbon\Carbon::create(2018,1,6),
                    'end_at' => \Carbon\Carbon::create(2018,1,17),
                    'created_at' => \Carbon\Carbon::create(2017,12,29, 17),
                ]
            );
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        if (app()->environment() !== 'production') {
            Schema::dropIfExists($this->table_name);
        }
    }
}
